# http://mutelight.org/practical-tmux

# Set XTerm key binding
setw -g xterm-keys on

# Set escape delay
# https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed
set-option -g escape-time 50

# Set colors
set-option -g default-terminal "screen-256color"

set-option -g prefix m-`
bind-key m-` send-prefix

# Use vim bindings
setw -g mode-keys vi

# Count sessions start at 1
set -g base-index 1

# Remap window navigation to vim
unbind-key j
bind-key j select-pane -D 
unbind-key k
bind-key k select-pane -U
unbind-key h
bind-key h select-pane -L
unbind-key l
bind-key l select-pane -R

# Fast window navigation
bind -n C-M-h select-pane -L
bind -n C-M-j select-pane -D
bind -n C-M-k select-pane -U
bind -n C-M-l select-pane -R
bind -n C-M-n next-window
bind -n C-M-p previous-window

# Reload source 
bind r source-file ~/.tmux.conf

# Set the title bar
set -g set-titles on
set -g set-titles-string '#(whoami)@#h :: [#S]'

# Set the default shell
# set-option -g default-shell /usr/bin/zsh

# Enable mouse support in ~/.tmux.conf
set -g mouse on
# set -g terminal-overrides 'xterm*:smcup@:rmcup@'

bind m setw -g mouse off \; display "Mouse OFF!" 
bind M setw -g mouse on \; display "Mouse ON!"

# Set status bar
# set -g status-utf8 on
set -g status-bg colour6
set -g status-fg black
set -g status-interval 5 
set -g status-left-length 90
set -g status-right-length 60
# set -g status-left "#[fg=red]#(whoami)#[fg=white]::#[fg=blue]#(hostname -s)#[fg=white]::#[fg=black]#(curl ipecho.net/plain;echo) - "
set -g status-left "#[fg=blue]#(whoami)@#(hostname -s)#[fg=white]::#[fg=black][#S]#[fg=white]::#[fg=red]#(curl ipecho.net/plain;echo)#[fg=white] - "
set -g status-justify left
set -g status-right '#[fg=Cyan]#S #[fg=blue]%a %d %b %R'

setw -g automatic-rename on
set-window-option -g window-status-format '#[dem]#I:#[white]#W#[fg=white,dem]'
set-window-option -g window-status-current-format '#[fg=white,bold]#I#[fg=white]:#[fg=white]#W#[fg=dim]'

# reload SSH_AUTH_SOCK every time
set -g update-environment "SSH_AUTH_SOCK"


